﻿using System;
using System.Collections.Generic;

namespace Factorial
{
    class Factorial
    {
        static void Print(byte[] numbers)
        {
            for (int i = numbers.Length - 1; i >= 0; i--)
            {
                Console.Write(numbers[i]);
            }
            Console.WriteLine();
        }

        static byte[] SumArray(byte[] firstArray, byte[] secondArray)
        {
            byte[] biggestArray = firstArray.Length > secondArray.Length ? firstArray : secondArray;
            List<byte> result = new List<byte>(biggestArray.Length + 1);
            int maxLength = Math.Min(firstArray.Length, secondArray.Length), carry = 0;

            for (int index = 0; index < maxLength; index++)
            {
                byte currentNumber = (byte)(firstArray[index] + secondArray[index] + carry);
                carry = currentNumber / 10;
                result.Add((byte)(currentNumber % 10));
            }

            for (int index = maxLength, length = biggestArray.Length; index < length; index++)
            {
                byte currentNumber = (byte)(biggestArray[index] + carry);
                carry = currentNumber / 10;
                result.Add((byte)(currentNumber % 10));
            }

            if (carry != 0)
            {
                result.Add(1);
            }

            return result.ToArray();
        }

        static byte[] Multiply(byte[] number, int times)
        {
            byte[] result = { 0 };

            for (int i = 0; i < times; i++)
            {
                result = SumArray(result, number);
            }

            return result;
        }

        static void Main()
        {
            byte[] factorial = { 1 };

            for (int i = 1; i <= 100; i++)
            {
                Print(factorial = Multiply(factorial, i));
            }
        }
    }
}
